Restoration = {
	Valid =
	function(unit, ignoreLoS)
		ignoreLoS = ignoreLoS or false
		if ccR.Unit.Exists(unit)
		and ccR.Unit.Is.Alive(unit)
		and ccR.Unit.Is.APlayer(unit)
		and ccR.Unit.Distance("player", unit) <= 40
		and (ignoreLoS or (not ignoreLoS and ccR.Unit.Is.InLineOfSight(unit)))
		then
			return true
		else
			return false 
		end
	end,
	Rejuvenation =
	function(unit, health, ignoreCombat)
		if ignoreCombat == nil then ignoreCombat = false end
		if Restoration.Valid(unit)
		and	ccR.Player.Has.Spell("Rejuvenation")
		and ccR.Spell.Is.Ready("Rejuvenation")
		and ccR.Unit.Health(unit) <= health
		and ((not ignoreCombat and ccR.Unit.Is.InCombat(unit)) or ignoreCombat)
		and not ccR.Unit.Has.MyBuff(unit, "Rejuvenation")
		then ccR.StopCasting("Wrath", 0.2)
			ccR.Cast.Spell("Rejuvenation", unit)
		end	
	end,
	Germination =
	function(unit, health)
		if Restoration.Valid(unit)
		and ccR.Player.Has.Talent("Germination")
		and	ccR.Player.Has.Spell("Rejuvenation")
		and ccR.Spell.Is.Ready("Rejuvenation")
		and ccR.Unit.Health(unit) <= health
		and not ccR.Unit.Has.MyBuff(unit, "Rejuvenation (Germination)")
		then ccR.StopCasting("Wrath", 0.2)
			ccR.Cast.Spell("Rejuvenation", unit)
		end	
	end,
	Genesis =
	function(unit, health, count)
		if Restoration.Valid(unit)
		and	ccR.Player.Has.Spell("Genesis")
		and ccR.Spell.IsReady("Genesis")
		and ccR.Unit.Has.MyBuff(unit, "Rejuvenation")
		and ccR.Unit.Health(unit) <= health
		then
			local vCount = 0
			for i = 1, # ccR_Friendly do
				local vUnit = ccR_Friendly[i]
				if Restoration.Valid(unit, true)
				and ccR.Unit.Distance(unit, vUnit) <= 60
				and ccR.Unit.Has.MyBuff(vUnit, "Rejuvenation")		
				and ccR.Unit.Health(vUnit) <= health
				then
					vCount = vCount + 1
				end
			end
			if vCount >= count then ccR.StopCasting("Wrath", 0.2)
				ccR.Cast.Spell("Genesis", unit)
			end	
		end
	end,
	WildGrowth =
	function(unit, health, count)
		if Restoration.Valid(unit)
		and	ccR.Player.Has.Spell("Wild Growth")
		and ccR.Spell.IsReady("Wild Growth")
		and ccR.Player.Mana() > 5
		and not ccR.Player.IsMoving()
		and (ccR.Player.HasTalent("Soul of the Forest") and ccR.Player.HasBuff("Soul of the Forest") or not ccR.Player.HasTalent("Soul of the Forest"))
		and ccR.Unit.Health(unit) <= health
		then
			local vCount = 0
			for i = 1, # ccR_Friendly do
				local vUnit = ccR_Friendly[i]
				if Restoration.Valid(unit, true)
				and ccR.Unit.Distance(unit, vUnit) <= 30	
				and ccR.Unit.Health(vUnit) <= health
				then
					vCount = vCount + 1
				end
			end
			if vCount >= count then ccR.StopCasting("Wrath", 0.2)
				ccR.Cast.Spell("Wild Growth", unit)
			end	
		end
	end,
	WildGrowthFiller =
	function(unit, health, count)
		if ccR.Unit.Exists("Boss1") 
		and ccR.Player.Mana() > ccR.Unit.Health("Boss1")
		and ccR.Player.Mana() > ccR.Unit.Health("Boss2")
		and ccR.Player.Mana() > ccR.Unit.Health("Boss3")
		and ccR.Player.Mana() > ccR.Unit.Health("Boss4")
		and ccR.Player.Mana() > ccR.Unit.Health("Boss5")
		or ccR.Player.Mana() >= 95 
		or not ccR.Unit.Exists("Boss1") then
			if Restoration.Valid(unit)
			and	ccR.Player.Has.Spell("Wild Growth")
			and ccR.Spell.IsReady("Wild Growth")
			and ccR.Player.Mana() > 5
			and not ccR.Player.IsMoving()
			and ccR.Unit.Health(unit) <= health
			then
				local vCount = 0
				for i = 1, # ccR_Friendly do
					local vUnit = ccR_Friendly[i]
					if Restoration.Valid(unit, true)
					and ccR.Unit.Distance(unit, vUnit) <= 30	
					and ccR.Unit.Health(vUnit) <= health
					then
						vCount = vCount + 1
					end
				end
				if vCount >= count then ccR.StopCasting("Wrath", 0.2)
					ccR.Cast.Spell("Wild Growth", unit)
				end
			end	
		end
	end,
	AutoLifeBloom =
	function(unit, health, ignoreCombat)
		if ignoreCombat == nil then ignoreCombat = false end
		if Restoration.Valid(unit)
		and	ccR.Player.Has.Spell("Lifebloom")
		and ccR.Spell.Is.Ready("Lifebloom")
		and ccR.Unit.Health(unit) <= health
		and ((not ignoreCombat and ccR.Unit.Is.InCombat(unit)) or ignoreCombat)
		and not ccR.Unit.Has.MyBuff(unit, "Lifebloom")
		then ccR.StopCasting("Wrath", 0.2)
			ccR.Cast.Spell("Lifebloom", unit)
		end	
	end,
	IronBark =
	function()
		if ccR.Unit.Exists(RejShroom) and ccR.Spell.Is.Ready(IRONBARK) and not ccR.Unit.Has.Buff(RejShroom, IRONBARK) and ccR.Unit.Health(RejShroom) < 50 then
			ccR.Cast.Spell(IRONBARK, RejShroom)
		elseif Tank1 and ValidToHeal(Tank1) and ccR.Spell.Is.Ready(IRONBARK) and not ccR.Unit.Has.Buff(Tank1, IRONBARK) and (ccR.Unit.Health(Tank1) < 40 or ccR.Unit.Has.Debuff(Tank1, 159220)) then
			ccR.Cast.Spell(IRONBARK, Tank1)
		elseif Tank2 and ValidToHeal(Tank2) and ccR.Spell.Is.Ready(IRONBARK) and not ccR.Unit.Has.Buff(Tank2, IRONBARK) and (ccR.Unit.Health(Tank2) < 40 or ccR.Unit.Has.Debuff(Tank2, 159220)) then
			ccR.Cast.Spell(IRONBARK, Tank2)
		elseif not Tank2 and not Tank1 and ccR.Spell.Is.Ready(IRONBARK) and LowestHP and ValidToHeal(LowestHP) and not ccR.Unit.Has.Buff(LowestHP, IRONBARK) and ccR.Unit.Health(LowestHP) < 40 then
			ccR.Cast.Spell(IRONBARK, LowestHP)
		--elseif ccR.Unit.Exists("Oto The Protector") and ccR.Spell.Is.Ready(IRONBARK) and not ccR.Unit.Has.MyBuff("Oto The Protector", IRONBARK) and ccR.Unit.Health("Oto The Protector") < 60 then
		--	ccR.Cast.Spell(IRONBARK, "Oto The Protector")
		end
	end,
	Sooth =
	function()
		if ccR.Spell.Is.Ready(SOOTH) and (tLastSoothUsed == nil or (GetTime()-tLastSoothUsed >= 1.0)) then
			for x = 1, # ccR_Enemies_In_Combat do
				local vUnit = ccR_Enemies_In_Combat[x]
				if ccR.Unit.Exists(vUnit) and ccR.Unit.Distance("player", vUnit) <= 40 then
					for i = 1, 40 do 
					 	local name, _, _, _, buffType = UnitAura(vUnit, i) 
					 	if name == nil then	break else if buffType == "" then ccR.Cast.Spell(SOOTH, vUnit) tLastSoothUsed = GetTime() ccR.PrintToChat("Sooth: " .. name .. " from " .. ccR.Unit.Name(vUnit)) return end end
					end
				end
			end
		end
	end,
	FindThreat =
	function()
		for x = 1, # ccR_Enemies_In_Combat do
			local vUnit = ccR_Enemies_In_Combat[x]
			if ccR.Unit.Is.Alive(vUnit)
			
			and ccR.Unit.Is.Attackable(vUnit)
			
			
			and ccR.Unit.Is.InCombat(vUnit)
			then
				if ccR.Unit.Is.Boss(vUnit) then
					BossTarget = vUnit
				else
					TrashUnit = vUnit
				end

			end
		end
	end,
	AutoWrath = 
	function()
		if not ccR.Player.Is.Moving() and ccR.Player.Has.Talent(DREAM_OF_CENARIUS) and ccR.Unit.Exists("target") and ccR.Target.Is.Attackable() and ccR.Player.Is.Facing("target") and ccR.Spell.Is.Ready(WRATH) and ccR.Spell.CanAttack(WRATH, "target") then
			ccR.Cast.Attack(WRATH, "target")
		else
			for x = 1, # ccR_Enemies_In_Combat do
				local vUnit = ccR_Enemies_In_Combat[x]
				if ccR.Unit.Is.Alive(vUnit)
				and ccR.Player.Is.Facing(vUnit)
				and ccR.Spell.CanAttack(WRATH, vUnit)
				and ccR.Player.Has.Talent(DREAM_OF_CENARIUS)
				and not ccR.Player.Is.Moving()
				and ccR.Unit.Is.InCombat(vUnit)
				then
					ccR.Cast.Attack(WRATH, vUnit)
				end
			end
		end
	end,
	Regrowth =
	function(unit, health)
		if Restoration.Valid(unit)
		and ccR.Spell.Is.Ready("Regrowth")
		and	ccR.Player.Has.Spell("Regrowth")
		and ccR.Spell.CanAttack("Regrowth", unit)
		and ccR.Unit.Health(unit) <= health
		and not ccR.Player.Is.Moving() 
		then ccR.StopCasting("Wrath", 0.2)
			ccR.Cast.Spell("Regrowth", unit)
		end
	end,
	HealingTouch =
	function(unit, health)
		if Restoration.Valid(unit)
		and ccR.Spell.Is.Ready("Healing Touch")
		and	ccR.Player.Has.Spell("Healing Touch")
		and ccR.Spell.CanAttack("Healing Touch", unit)
		and ccR.Unit.Health(unit) <= health
		and not ccR.Player.Is.Moving()
		then ccR.StopCasting("Wrath", 0.2)
			ccR.Cast.Spell("Healing Touch", unit)
		end
	end,
	NaturesCure =
	function(unit)
		if Restoration.Valid(unit)
		and ccR.Player.Level() >= 22
		and ccR.Player.Has.Spell("Nature's Cure")
		and ccR.Spell.Is.Ready("Nature's Cure")
		then
			for i = 1, 40 do 
			 	local name, _, _, _, debuffType, _, _, _, _, _, debuffID = UnitDebuff(unit, i) 
			 	if name == nil then	
			 		break 
			 	else 
			 		if debuffType == "Curse"
			 		or debuffType == "Magic"
			 		or debuffType == "Poison"
			 		then
			 			if not ccR.Unit.Has.Debuff(unit, "Convulsive Shadows") then ccR.Cast.Spell("Nature's Cure", unit) end
			 			return
			 		end
			 	end
			end
		end
	end,
	WildMushroom =
	function(unit)
		if ccR.Spell.Is.Ready("Wild Mushroom")
		and ccR.Player.IsInCombat()
		and not ccR.Player.HasTotem("Wild Mushroom")	
		then ccR.StopCasting("Wrath", 0.2)
			ccR.Cast.Spell("Wild Mushroom")
		end
	end,
	TreAnt = 
	function()
		if ccR.Player.HasGlyph(125047) then
			if not ccR.Player.HasBuff(114282) and not ccR.Player.HasBuff("Dash") and not ccR.Player.HasBuff("Incarnation: Tree of Life") then ccR.Cast.Spell(114282) end
		end
	end,
	Swiftmend =
	function()
		for i = 1, # ccR_Friendly do 
			local vUnit = ccR_Friendly[i]
			if Restoration.Valid(vUnit)
			and ccR.Spell.Is.Ready(18562, true)
			and (ccR.Unit.Has.Buff(vUnit, "Rejuvenation") or ccR.Unit.Has.Buff(vUnit, "Regrowth"))
			then ccR.StopCasting("Wrath", 0.2)
				ccR.Cast.Spell(18562, vUnit, false, true)
			end	
		end
	end,					
}